[org 0x7c00]
KERNEL_OFFSET equ 0x1000

; bp sp不手动设置时会有一个随机地址可能导致系统崩溃
mov bp, 0x8000 ; 0x8000 - 0x7c00 - 512 = 512字节可用
mov sp, bp

mov bx, MSG_LOAD_KERNEL
call print
call print_nl

mov dh, 0x02    ; 扇区数量
mov bx, KERNEL_OFFSET ; 内加载到这里
call disk_load

mov bx, MSG_ENTER_PM
call print
call print_nl
call switch_to_pm
jmp $

%include "../chapter5/boot_sect_print.asm"
%include "../chapter7/boot_sect_disk.asm"
%include "../chapter8-9-10/32bit-gdt.asm"
%include "../chapter8-9-10/32bit-switch.asm"

[bits 32]
BEGIN_PM:
    call KERNEL_OFFSET
    jmp $
MSG_LOAD_KERNEL:
    db "start load kernel", 0
MSG_ENTER_PM:
    db "start enter protected mode", 0

times 510 - ($ - $$) db 0x00

dw 0xaa55